﻿@{
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "Select a game";
        var db = Database.Open("ICRams");
         
        var games = db.Query(@"SELECT Games.Id, Games.Opponent, Games.OurScore, Games.OpponentScore, Games.GameDate, Games.HomeAway  FROM Games
                                ORDER BY Games.GameDate ASC");
        
        db.Close();
        
        var entryMode = Request["EntryMode"];
}

    <h3>Games:</h3>
<p>
    @foreach(var game in games){
        <a href="Default?GameId=@game.Id" >@game.HomeAway @game.Opponent on @game.GameDate.ToShortDateString()</a> 
    <span>Score: IC: </span><span class="score">@game.OurScore</span><span> - </span><span>@game.Opponent : </span><span class="score">@game.OpponentScore</span>
    if(!string.IsNullOrEmpty(entryMode)){
        <a href="/EnterGameStats?GameId=@game.Id">Add player stats for this game</a>
    }
    <br /><br />
    }
</p>